package com.cs.study.homework._0222;

public class Demo1 {
    public static void main(String[] args) {
        Staff staff;
        staff = new NormalStaff("ls", 1, 3000);
        staff.printInfo();
        staff.work();

        staff = new Coder("ls", 2, 12000);
        staff.printInfo();
        staff.work();
        if (staff instanceof Coder) {
            ((Coder) staff).overTimeWork();
        }

        staff = new Manger("ww", 3, 15000);
        staff.printInfo();
        staff.work();

    }
}

abstract class Staff {
    private String name;
    private int id;
    private double salary;

    public Staff(String name, int id, double salary) {
        this.name = name;
        this.id = id;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public abstract void work();

    public void printInfo() {
        System.out.println("姓名：" + name + " 工号：" + id + " 工资：" + salary);
    }
}

class NormalStaff extends Staff {
    public NormalStaff(String name, int id, double salary) {
        super(name, id, salary);
    }

    @Override
    public void work() {
        System.out.println("工作是负责杂项工作");
    }
}

class Coder extends Staff {

    public Coder(String name, int id, double salary) {
        super(name, id, salary);
    }

    @Override
    public void work() {
        System.out.println("工作是负责技术开发");
    }

    public void overTimeWork() {
        System.out.println("加班");
    }
}

class Manger extends Staff {
    public Manger(String name, int id, double salary) {
        super(name, id, salary);
    }

    @Override
    public void work() {
        System.out.println("工作是负责统筹规划");
    }
}
